package com.cqie.controller.entrepot;

import com.cqie.dto.entrepot.EntrepotRecordInfoListDto;
import com.cqie.entity.EntrepotRecordInfo;
import com.cqie.exception.SpecialException;
import com.cqie.service.IEntrepotRecordInfoService;
import com.cqie.util.ResultTemplate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 仓库进取记录表 前端控制器
 * </p>
 *
 * @author 不吃海鲜
 * @since 2024-12-19
 */

@Tag(name = "仓库记录信息Controller", description = "描述：仓库记录信息接口")
@RestController
@RequestMapping({"/api/v1.0/entrepotRecordInfo", "/api/v1/entrepotRecordInfo"})
public class EntrepotRecordInfoController {

    @Autowired
    private IEntrepotRecordInfoService entrepotRecordInfoService;

    @Operation(summary = "根据仓库id查询仓库药品信息")
    @GetMapping("/getEntrepotRecordInfoByWarehouseId")
    public ResultTemplate<List<EntrepotRecordInfoListDto>> getEntrepotRecordInfoByWarehouseId(String warehouseId) {
        return ResultTemplate.Success(entrepotRecordInfoService.getEntrepotRecordInfoByWarehouseId(warehouseId));
    }

    @Operation(summary = "根据仓库id查询进货取货记录")
    @Parameters({
            @Parameter(name = "warehouseId", description = "仓库id"),
            @Parameter(name = "drugCode", description = "药品编码")
    })
    @GetMapping("/getEntrepotRecordInfoByMedicineId")
    public ResultTemplate<List<EntrepotRecordInfoListDto>> getEntrepotRecordInfoByMedicineId(
            @RequestParam(required = false , defaultValue = "") String warehouseId ,
            @RequestParam(required = false , defaultValue = "") String drugCode ,
            @RequestParam(required = false , defaultValue = "12") Integer pageSize ,
            @RequestParam(required = false , defaultValue = "1") Integer pageIndex) throws SpecialException {
        return ResultTemplate.Success(entrepotRecordInfoService.getEntrepotRecordInfoByMedicineId(warehouseId,
                drugCode , pageSize , pageIndex));
    }

}
